import React from 'react';
import { Text, View } from 'react-native';
import _ from 'lodash';
import { observer } from 'mobx-react';
import { Actions } from 'react-native-router-flux';
import user from '../../../../common/models/user';
import Button from '../../../../components/Button';
import styles from './style';

@observer
class Not extends React.Component {
  hasApplied = (status) => {
    if (status) {
      const { insuranceOrgName, insuranceOrgPostName } = status;
      return (
        <View style={styles.block}>
          <Text>您已经申请加入了{insuranceOrgName}, 职级为{insuranceOrgPostName}, 审核中...</Text>
        </View>
      );
    }
  }
  render() {
    if (this.props.user.userInfo.insuranceOrgId) {
      return null;
    }
    if (!_.isEmpty(this.props.user.applyStatus)) {
      return this.hasApplied(this.props.user.applyStatus);
    }
    return (
      <View style={styles.block}>
        <Text style={styles.text}>
          您没有加入机构, 只能浏览公共活动信息
        </Text>
        <View style={styles.naBtn}>
          <Button
            title="申请加入机构"
            type="primary"
            size="small"
            onPress={Actions.checkInstitution}
          />
        </View>
      </View>
    );
  }
}

export default Not;
